package routers

import (
	"Squid/controllers"
	"github.com/labstack/echo/v4"
)

func JobGroupRoute(e *echo.Group) error {
	var (
		jobController *controllers.JobController
		err error
	)

	if jobController, err = controllers.NewJobController(); err != nil {
		return err
	}

	e.POST("", jobController.SaveJob)//添加job
	e.GET("/:id", jobController.GetJob) //获取某个job
	e.PUT("/:id", jobController.UpdateJob)//修改job
	e.DELETE("/:id", jobController.DeleteJob)//删除job
	e.GET("/jobs", jobController.GetJobs)//分页获取job

	e.POST("/sync", jobController.SyncJobEtcd)//同步mysql的数据到etcd
	e.DELETE("/etcd/:id", jobController.DeleteJobEtcd)//删除etcd的job任务
	e.GET("/etcd/list", jobController.GetEtcdJobs)//获取etcd中在运行的job任务
	//e.GET("/etcd/:id", controllers.GetJobEtcd)//检测etcd中的job
	e.POST("/etcd/kill", jobController.KillJobEtcd)//杀死etcd中的job
	//e.GET("/etcd/log/:id", controllers.GetJobLog)//查看任务日志


	e.GET("/workers", jobController.GetWorkers)//获取worker节点


	return err
}

